package com.yc.cloud.basic.config;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import java.io.File;

/**
 * @Author Kent Jiang
 * @Date 2020/6/4 17:00
 * @Version 1.0
 */
@Component
@ConfigurationProperties(prefix = "custom.path")
public class PathConfig {

    private String basePath;

    private String baseUrl;

    private String tempBasePath;

    public String getBasePath() {
        return basePath;
    }

    public void setBasePath(String basePath) {
        this.basePath = basePath;
    }

    public String getBaseUrl() {
        return baseUrl;
    }

    public void setBaseUrl(String baseUrl) {
        this.baseUrl = baseUrl;
    }

    public String getTempBasePath() {
        if (!new File(tempBasePath).exists()) {
            new File(tempBasePath).mkdirs();
        }
        return tempBasePath;
    }

    public void setTempBasePath(String tempBasePath) {
        this.tempBasePath = tempBasePath;
    }
}
